using System;
using System.Linq.Expressions;

namespace Caramel
{
	public class Specification<T> : ISpecification<T>
	{
		public Specification(Expression<Func<T, bool>> predicate)
		{
			this.Predicate = predicate;
		}

		#region ISpecification<T> Members

		public Expression<Func<T, bool>> Predicate { get; private set; }

		public bool IsSatifiedBy(T value)
		{
			return this.Predicate.Compile().Invoke(value);
		}

		#endregion
	}
}
